package com.example.treeHole.controller;

import com.example.treeHole.result.Result;
import com.example.treeHole.service.ArticleCategoryService;
import com.example.treeHole.vo.ArticleCategory;
import com.example.treeHole.vo.ArticleReply;
import com.example.treeHole.vo.dto.ArticleCategoryDto;
import com.example.treeHole.vo.dto.ArticleReplyDto;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/articleCategory")
public class ArticleCategoryController {

    @Autowired
    private ArticleCategoryService articleCategoryService;

    @GetMapping("/findAll")
    public Result<List<ArticleCategory>> findAll(){

        List<ArticleCategory> articleCategoryList = articleCategoryService.findAll();
        return Result.success(articleCategoryList);
    }

    @GetMapping("/page")
    public Result<PageInfo<ArticleCategory>> page(ArticleCategoryDto ArticleCategoryDto){
        PageInfo<ArticleCategory> pageInfo = articleCategoryService.page(ArticleCategoryDto);
        return Result.success(pageInfo);
    }
    @GetMapping("/findById/{id}")
    public Result<ArticleCategory> findByid(@PathVariable String id){
        ArticleCategory articleCategory=articleCategoryService.findById(id);
        return Result.success(articleCategory);
    }
}
